package org.opens.emp.service.impl;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;
import org.opens.emp.dao.EmpDao;
import org.opens.emp.entity.EmpEntity;
import org.opens.emp.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;

@Service
@Slf4j
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpDao empDao;

    @Override
    public EmpEntity save(EmpEntity empEntity) {
        Assert.notNull(empEntity, "插入数据不能为null！");

        empEntity.setId(IdUtil.simpleUUID());

        empDao.insert(empEntity);

        return empEntity;
    }

    @Override
    public EmpEntity getById(Serializable id) {
        Assert.notNull(id, "查询数据是id不能为null！");

        return empDao.selectById(id);
    }
}
